package com.woniuxy.factory.controller;

import com.woniuxy.factory.entity.OtherIn;
import com.woniuxy.factory.entity.ResponseResult;
import com.woniuxy.factory.service.OtherInService;
import com.woniuxy.factory.util.AuditType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 邹佳骏
 * @date 2020-08-23 2:18
 * @name 物料/劳保入库controller
 */
@Controller
public class OtherInController {

    @Autowired
    OtherInService otherInService;

    @ResponseBody
    @GetMapping("/otherin")
    public ResponseResult<List<OtherIn>> getAllMaterialOut(int page, int limit,OtherIn otherIn
            ,String pupId,String searchDate){
        ResponseResult<List<OtherIn>>  responseResult = new ResponseResult<>();
        int count =  otherInService.selectAllCount();
        List<OtherIn> otherIns = otherInService.selectAllOtherIn(page,limit,otherIn,pupId,searchDate);
        responseResult.setMsg("查询成功");
        responseResult.setCode(AuditType.No_Approval);
        responseResult.setData(otherIns);
        responseResult.setCount(count);
        return responseResult;
    }

    @ResponseBody
    @RequestMapping("/updateotherin")
    public ResponseResult updateOtherIn(OtherIn otherIn,String pupId){
        ResponseResult responseResult = otherInService.updateOtherIn(otherIn,pupId);
        return responseResult;
    }
}
